import request from '@/utils/request'

const baseUrl = '/cz-rentbox/api/v1/callbackOrders' //回调箱服务--回调箱订单
// import {updateCallbackOrderPrice } from '@/api/boxCallBack/order'

/* 
# 集装箱公司查询自己的回调箱订单分页列表
# POST {{baseUrl}}/callbackOrders/boxEastSelfCallbackOrderPage
# 过滤条件：回调订单号:String orderNo 创建时间时间区间:beginCreateDate endCreateDate
# 预计提箱日期  LocalDateTime beginPlanPickupDate  LocalDateTime endPlanPickupDate
# 出发城市Id: carryCityId 到达城市Ids: List<Long> returnCityIds
# 订单状态 5-待开提箱单 10-待提 15-已提 20-待还 25-已还未付/已还已付 30-已完成 35-已取消
*/
export const getBoxEastSelfTable = (data: any) => {
    return request({
        url: baseUrl + '/boxEastSelfCallbackOrderPage',
        method: 'post',
        data: data
        // data:{
        // "orderNo":"HDOID2024073053645251",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "carryCityId":"2",
        // "pageNum": 1,
        // "pageSize": 10
        // }
    })
}

/* 
# 集装箱公司查询自己 可开提箱单 的回调箱订单分页列表
# POST {{baseUrl}}/callbackOrders/boxEastSelfCallbackOrderPackingListPage
# 过滤条件：回调订单号:String orderNo 创建时间时间区间:beginCreateDate endCreateDate
# 预计提箱日期  LocalDateTime beginPlanPickupDate  LocalDateTime endPlanPickupDate
# 出发城市Id: carryCityId 到达城市Ids: List<Long> returnCityIds 
*/
export const boxEastSelfCallbackOrderPackingListPage = (data: any) => {
    return request({
        url: baseUrl + '/boxEastSelfCallbackOrderPackingListPage',
        method: 'post',
        data: data
        // data:{
        // "orderNo":"HDOID2024073053645251",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "carryCityId":"2",
        // "pageNum": 1,
        // "pageSize": 10
        // }
    })
}


/* 
# 货代查询自己的回调箱订单分页列表
# POST {{baseUrl}}/callbackOrders/agentEastSelfCallbackOrderPage
# 过滤条件：回调订单号:String orderNo 创建时间时间区间:beginCreateDate endCreateDate
# 预计提箱日期  LocalDateTime beginPlanPickupDate  LocalDateTime endPlanPickupDate
# 出发城市Id: carryCityId 到达城市Ids: List<Long> returnCityIds
# 订单状态 5-待开提箱单 10-待提 15-已提 20-待还 25-已还未付/已还已付 30-已完成 35-已取消
*/
export const getAgentSelfTable = (data: any) => {
    return request({
        url: baseUrl + '/agentEastSelfCallbackOrderPage',
        method: 'post',
        data: data
        // data:{
        // "orderNo":"HDOID2024073053645251",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "beginCreateDate":"2024-06-01T18:21:19",
        // "endCreateDate":"2024-06-138T18:21:19",
        // "carryCityId":"2",
        // "pageNum": 1,
        // "pageSize": 10
        // }
    })
}

/* 
 # 根据id查询订单详情
# GET {{baseUrl}}/rentOrders/{id}
*/
export const getOrderData = (id: any) => {
    return request({
        url: baseUrl + '/' + id,
        method: 'GET'
    })
}

/* 
# 查询自己的回调箱订单价格列表
# POST {{baseUrl}}/callbackOrders/boxEastSelfCallbackOrderPage
# 过滤条件：回调订单号:String orderNo 回调订单id:Long orderId
*/
export const getOrderPrices = (data: any) => {
    return request({
        url: '/cz-rentbox/api/v1/callbackOrderPrices/list',
        method: 'post',
        data: data
        // data:{
        // "orderId": 1,
        // "orderNo": "HDOID2024073053645252"
        // }
    })
}

/* 
### 修改回调箱订单价格
## PUT  {{baseUrl}}/callbackOrderPrices/updateCallbackOrderPrice
[{
      "id":87,
      "unitPrice":100
}]
*/
export const updateCallbackOrderPrice = (data: any) => {
    return request({
        url: '/cz-rentbox/api/v1/callbackOrderPrices/updateCallbackOrderPrice',
        method: 'post',
        data: data
        //  [{
        //     "id":87,
        //     "unitPrice":100
        //  }]
    })
}

/* 
* 集装箱公司发布，货代新增回调箱订单
*/
export const addBoxCallbackOrder = (data: any) => {
    return request({
        url: baseUrl + '/addBoxCallbackOrder',
        method: 'post',
        data: data
        // data:{
        // "releaseCallbackId":32,
        // "carryCityId":1,
        // "carryCityName":"北京",
        // "carryCountryId":1,
        // "carryCountryName":"中国",
        // "planPickupDate":"2024-07-15T18:21:19",
        // "boxType":5,
        // "boxCondition":5,
        // "couponAmount":100,
        // "paymentMethod":5,
        // "contacts":"张三",
        // "tel":"12345678901",
        // "leaveMsg":"留言",
        // "allocation": "[{\"operateUserId\": 1,\"operateUserName\": \"操作员\",\"businessUserId\": 2,\"businessUserName\": \"业务员\",\"businessNo\": \"NO1234567890\",\"handleUserId\": 3,\"handleUserName\": \"经办人\"}]",
        // "callbackOrderPriceBeans":[
        //     {
        //         "returnCityId":1,
        //         "returnCityName":"郑州",
        //         "returnCountryId":1,
        //         "returnCountryName":"中国",
        //         "unitPrice":100,
        //         "boxQuantity":10,
        //         "unitSubtotal":1000
        //     }
        // ]
        // }
    })
}


/*  
* 货代发布，集装箱公司新增回调箱订单
*/
export const addAgentCallbackOrder = (data: any) => {
    return request({
        url: baseUrl + '/addAgentCallbackOrder',
        method: 'post',
        data: data
        //   {
        //   "releaseRentId":32,
        //   "carryCityId":1,
        //   "carryCityName":"北京",
        //   "carryCountryId":1,
        //   "carryCountryName":"中国",
        //   "planPickupDate":"2024-07-15T18:21:19",
        //   "boxType":5,
        //   "boxCondition":5,
        //   "boxQuantity":10,
        //   "couponAmount":100,
        //   "amount":100,
        //   "actualPayAmount":100,
        //   "paymentMethod":5,
        //   "contacts":"张三",
        //   "tel":"12345678901",
        //   "leaveMsg":"留言",
        //   "remark":"备注",
        //   "callbackOrderPriceBeans":[
        //       {
        //           "returnCityName":"郑州",
        //           "returnCountryId":1,
        //           "returnCountryName":"中国",
        //           "unitPrice":100,
        //           "boxQuantity":10,
        //           "unitSubtotal":1000

        //       }
        //   ]
        // }

    })
}

/* 
* 取消订单
* PUT  {{baseUrl}}/callbackOrders/{id}/cancelCallbackOrder
*/
export const cancelCallbackOrder = (data: { id: any, remark: string }) => {
    return request({
        url: baseUrl + '/' + data.id + '/cancelCallbackOrder',
        method: 'PUT',
        data: data
    })
}


/* 
### 修改回调箱订单
## PUT  {{baseUrl}}/callbackOrders/{id}/updateCallbackOrder
{
  "callbackOrderPriceBeans":[
    {
      "id":44,
      "unitPrice":100, 
      "boxQuantity":10
    }
  ],
  "boxUsagePeriod":60,
  "boxQuantity":40,
  "amount":400,
  "actualPayAmount":4000,
  "allocation": "[{\"operateUserId\": 1,\"operateUserName\": \"操作员\",\"businessUserId\": 2,\"businessUserName\": \"业务员\",\"businessNo\": \"NO1234567890\",\"handleUserId\": 3,\"handleUserName\": \"经办人\"}]", 

  "overdueFeeDay":10,
  "lossDay":10,
  "lossFee":10,
  "boxEastOperatorUserId": 2,
  "boxEastOperatorUserName": "张四三",
  "boxEastOperatorUserAreaCode": "86",
  "boxEastOperatorUserTel": "13217819303",
}
*/
export const updateCallbackOrder = (data: any) => {
    return request({
        url: baseUrl + '/' + data.id + '/updateCallbackOrder',
        method: 'PUT',
        data: data
    })
}


/* 
# 根据订单id获取提箱单详情
# GET {{baseUrl}}/callbackOrders/getPackingListById/{id}
*/
export const getPackingListById = (id: any) => {
    return request({
        url: baseUrl + '/getPackingListById/' + id,
        method: 'GET'
    })
}

/* 
### 批量已完成提箱
## PUT  {{baseUrl}}/callbackOrders/accomplishCallbackOrder
* data：[33,34]
*/
export const accomplishCallbackOrder = (data: any) => {
    return request({
        url: baseUrl + '/accomplishCallbackOrder',
        method: 'PUT',
        data: data
    })
}


/*
# 还箱:集装箱公司查询自己的订单列表
# POST {{baseUrl}}/rentOrders/boxEastSelectReturnOrderList
*/
export const boxEastSelectReturnOrderList = (data: any) => {
    return request({
        url: baseUrl + '/boxEastSelectReturnOrderList',
        method: 'POST',
        data: data,
        // data: { "orderIds":[123,1231] }
    })
}


/**
 # 查询回调箱订单应付管理
 # POST {{baseUrl}}/invoices/agentOrderDealWithPage
 # 集装箱箱号: List<String> containerNos
 # 还箱日期时间区间: LocalDateTime beginReturnDate  LocalDateTime endReturnDate
 # 提箱日期时间区间:   LocalDateTime beginPlanPickupDate  LocalDateTime endPlanPickupDate
 # 订单Id:orderId 订单编号:orderNo
 # 租赁集装箱货代公司Id:agentId  租赁集装箱货代公司名称:agentName
 data:{
 "containerNos":[jc123456789,jc0712002],
 "pageNum": 1,
 "pageSize": 10
 }
 */
export const agentOrderDealWithPage = (data: any) => {
    return request({
        url: baseUrl + '/agentOrderDealWithPage',
        method: 'post',
        data: data
    })
}


/**
 # 查询回调箱订单应收管理
 # POST {{baseUrl}}/invoices/getAgentOrderReceivablePage
 # 集装箱箱号: List<String> containerNos
 # 还箱日期时间区间: LocalDateTime beginReturnDate  LocalDateTime endReturnDate
 # 提箱日期时间区间:   LocalDateTime beginPlanPickupDate  LocalDateTime endPlanPickupDate
 # 订单Id:orderId 订单编号:orderNo
 # 租赁集装箱货代公司Id:companyId  租赁集装箱货代公司名称:companyName
 data:{
 "containerNos":[jc123456789,jc0712002],
 "pageNum": 1,
 "pageSize": 10
 }
 */
export const getAgentOrderReceivablePage = (data: any) => {
    return request({
        url: baseUrl + '/agentOrderReceivablePage',
        method: 'post',
        data: data
    })
}

/**
 ### 回调还箱新增到达城市
 ## POST  {{baseUrl}}/callbackOrders/addCallbackOrderRreturnCity
 {
 "id":"80",
 "callbackOrderPriceBeans":[
 {
 "unitPrice":0.00,
 "boxQuantity":5,
 "returnCityId":1,
 "returnCityName":"郑州1",
 "returnCountryId":1,
 "returnCountryName":"中国"
 },
 {
 "unitPrice":0.00,
 "boxQuantity":6,
 "returnCityId":1,
 "returnCityName":"郑州2",
 "returnCountryId":1,
 "returnCountryName":"中国"
 }
 ]
 }
 */
export const addCallbackOrderRreturnCity = (data: any) => {
    return request({
        url: baseUrl + '/addCallbackOrderReturnCity',
        method: 'post',
        data: data
    })
}

//箱东状态统计
export const boxEastStatusCount = (data: any) => {
    return request({
        url: baseUrl + '/boxEastStatusCount',
        method: 'post',
        data: data
    })
}
//货代状态统计
export const agentStatusCount = (data: any) => {
    return request({
        url: baseUrl + '/agentStatusCount',
        method: 'post',
        data: data
    })
}
//删除
export const deleteIds = (ids: any) => {
  return request({
    url: baseUrl,
    method: 'DELETE',
    data:ids
  })
}
/*
# 参数说明：
# 输入model
    # 分页条件加上查询条件
# 输出model:
    # 见最下方 ReturnBoxListDetailBean 字段说明
###
*/
export const exportBoxEastCallbackOrder = (orderIds: any) => {
    return request({
        responseType: 'blob',
        url: baseUrl + '/exportBoxEastCallbackOrder',
        method: 'POST',
        data: {
            "orderIds": orderIds
        },
        //  data: {
        //     "orderIds": [
        //         1813100172601262082,1813411122948669442
        //      ]
        // }
    })
}


/*
# 参数说明：
# 输入model
    # 查询条件订单Id的数组
# 输出model:
    # 见最下方 CallbackOrderBean 字段说明
###

###
# 货代回调箱订单:导出Excel文件
*/
export const exportAgentCallbackOrder = (orderIds: any) => {
    return request({
        responseType: 'blob',
        url: baseUrl + '/exportAgentCallbackOrder',
        method: 'POST',
        data: {
            "orderIds": orderIds
        },
        //  data: {
        //     "orderIds": [
        //         1813100172601262082,1813411122948669442
        //      ]
        // }
    })
}


/**
 * 进口箱箱东应付管理:导出Excel文件
 * @param data 参数
 */
export const exportBoxEastReturnBox = (data: any) => {
    return request({
        responseType: 'blob',
        url: baseUrl + '/exportBoxEastReturnBox',
        method: 'POST',
        data: data
    })
}

/**
 * 进口箱货代应收管理 :导出Excel文件
 * @param data 参数
 */
export const exportAgentReturnBox = (data: any) => {
    return request({
        responseType: 'blob',
        url: baseUrl + '/exportAgentReturnBox',
        method: 'POST',
        data: data
    })
}